<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'opportunity.label', default: 'Opportunity')}"/>
    <title>订单管理</title>
</head>
<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>Cake Store</li>
                    <li class="active">
                        <span>订单</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                订单
            </h2>
        </div>
    </div>
</div>
<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="searchOpportunity">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit"><i class="fa fa-search"></i>查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn"><i class="fa fa-times"></i>重置</button>
                    </div>
                    查询
                </div>

                <input type="hidden" name="status" id="status" value="${params.status}">
                <input type="hidden" name="stage" id="stage" value="${params.stage}">
                
                <div class="panel-body">
                    <div class="col-md-2">
                        <input type="text" class="form-control" placeholder="订单号" name="serialNumber" id="serialNumber" value="${params?.serialNumber}">
                    </div>

                    <div class="col-md-2">
                        <input type="text" class="form-control" placeholder="产品名称" name="productName" id="productName" value="${params?.productName}">
                    </div>

                    <div class="col-md-2">
                        <input type="text" class="form-control" placeholder="收货人姓名" name="fullName" id="fullName" value="${params?.fullName}">
                    </div>

                    <div class="col-md-2">
                        <input type="text" class="form-control" placeholder="收货人手机号" name="cellphone" id="cellphone" value="${params?.cellphone}">
                    </div>

                    <div class="col-md-2">
                        <div class="input-group date form_datetime">
                            <span class="input-group-addon">
                                <span class="fa fa-calendar"></span>
                            </span>
                            <input title="开始时间" type="text" name="startTime" id="startTime" value="${params?.startTime}" readonly class="form-control daily-b" placeholder="开始时间">
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="input-group date form_datetime">
                            <span class="input-group-addon">
                                <span class="fa fa-calendar"></span>
                            </span>
                            <input title="结束时间" type="text" name="endTime" id="endTime" value="${params?.endTime}" readonly class="form-control daily-b" placeholder="结束时间">
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
        <g:if test="${flash.message}">
            <div class="row">
                <div class="hpanel">
                    <div class="panel-body">
                        <div class="alert alert-info" role="alert">${flash.message}</div>
                    </div>
                </div>
            </div>
        </g:if>
    </div>
    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                  <sec:ifNotGranted roles="ROLE_COO">
                    <!-- <g:link action="create" class="btn btn-info btn-xs"><i class="fa fa-plus"></i>新建</g:link> -->
                  </sec:ifNotGranted>
                </div>
                所有订单
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <g:sortableColumn property="serialNumber" title="订单号"/>
                            <g:sortableColumn property="product.name" title="产品名称"/>
                            <g:sortableColumn property="quantity" title="数量"/>
                            <g:sortableColumn property="unitPrice" title="单价"/>
                            <g:sortableColumn property="totalPrice" title="总价"/>
                            <g:sortableColumn property="product.size" title="尺寸"/>
                            <g:sortableColumn property="fullName" title="姓名"/>
                            <g:sortableColumn property="cellphone" title="手机"/>
                            <g:sortableColumn property="address" title="收货地址"/>
                            <g:sortableColumn property="stage" title="订单阶段"/>
                            <g:sortableColumn property="status" title="订单状态"/>
                            <g:sortableColumn property="createdDate" title="提交时间"/>
                            <g:sortableColumn property="arrivalDate" title="送达时间"/>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${opportunityList}">
                            <tr>
                                <td><g:link action="show" id="${it?.id}" class="firstTd">${it?.serialNumber}</g:link></td>
                                <td>${it?.product?.name}</td>
                                <td>${it?.quantity}</td>
                                <td>${it?.unitPrice}</td>
                                <td>${it?.totalPrice}</td>
                                <td>${it?.size}</td>
                                <td>${it?.address?.fullName}</td>
                                <td>${it?.address?.cellphone}</td>
                                <td>${it?.address?.city}-${it?.address?.address}</td>
                                <td>${it?.stage?.name}</td>
                                <td>${it?.status}</td>
                                <td><g:formatDate format="yyyy-MM-dd HH:mm:ss" date="${it?.createdDate}"/></td>
                                <td><g:formatDate format="yyyy-MM-dd" date="${it?.arrivalDate}"/></td>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate total="${opportunityCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>
<g:javascript>
    $(function(){
        $("#resetBtn").click(function () {
            $("#serialNumber").val("");
            $("#productName").val("");
            $("#fullName").val("");
            $("#cellphone").val("");
            $("#startTime").val("");
            $("#endTime").val("");
        })
    });
</g:javascript>
</body>
</html>
